/* 
使用格式:
	1.引入公用样式表
	2.引入当前样式表
	3.引入公用js模块
	4.具体功能

*/

// 1.引入公用样式表
require("../../assets/css/index.less");

// 2.引入当前样式表
require("./addTrends.less");

// 3.引入公用js模块
let dom = require("../../utils/dom.js");
let https = require("../../utils/https.js");
require("../../assets/fonts/iconfont.css");

dom.ready(function () {
	dom.contFooter("sport");
	dom.getEle(".file").addEventListener("change", function () {
		// //获取文件
		let f = this.files[0];
		let fd = new FormData();
		fd.append("file", f);
		https.post("/api/circles/uploadImg", fd, function (res) {
			// console.log(res);
			if (res.errno === 0) {
				console.log(res);
				dom.getEle("#img").src = https.BASE_URL + res.data.url;
			}
		});
	});
	dom.getEle("#add").addEventListener("click", function () {
		// console.log(dom.getEle("#text").value);

		https.post(
			"/api/circles/opinion",
			{
				content: dom.getEle("#text").value,
				imgUrls: dom.getEle("#img").src,
				releaseProvinceId: 110000,
				releaseCityId: 110100,
			},
			function (res) {
				console.log(res);
			}
		);
	});
});
